<template>
  <div style="color: #666;font-size: 14px;">
    <div style="padding-bottom: 20px">
      <b>您好！{{ user }}</b>
    </div>
    <el-card shadow="hover">
      欢迎使用本系统
      <el-divider shadow="hover" />
      虎虎生威，虎年大吉
    </el-card>

    <el-card shadow="hover" style="margin-top: 20px;width: 300px">
      <div style="margin: 20px 0; font-size: 15px;color: #0d8d84;cursor: pointer">当前系统时间:{{ new Date().getFullYear() + '年' + (new Date().getMonth() + 1) + '月' + new Date().getDate() + '日' }}</div>
      <div
        style="width: 100px; height: 100px; line-height: 100px; border-radius: 50%; background-color: #1E90FF;
        font-size: 25px; color: #fff; text-align: center; cursor: pointer; box-shadow: 0 0 30px rgba(0, 0, 0, .2);"
        type="button"
        @click="sign"
      >
        打 卡
      </div>
    </el-card>
  </div>
</template>

<script>

import { reqPositioning } from '@/api/sign/sign'

export default {
  name: 'Daka',
  data() {
    return {
      user: localStorage.getItem('user') ? localStorage.getItem('user') : {},
      comments: ''
    }
  },
  methods: {
    async sign() {
      this.$confirm('你今天打卡了吗, 是否继续?', '定位打卡可获得20积分', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(async() => {
          const location = localStorage.getItem('location')
          // const password = localStorage.getItem('password')
          const username = this.user
          console.log(username)
          const sign = {
            username: username,
            location: location,
            comments: this.comments
          }
          const res = await this.$API.sign.reqPositioning(sign)
          if (res.code === 200) {
            this.$message({
              type: 'success',
              message: '已打卡成功'
            })
          }
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消打卡'
          })
        })
    }
  }
}
</script>
<style scoped>


</style>

